package com.example.demo.mapper;


import com.example.demo.model.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserinfoDao {


    @Results(id="BaseMap",value = {
            @Result(column = "good_acc",property = "goodacc"),
            @Result(column = "good_acc",property = "goodacc")
    })


/*    @ResultMap(value = "BaseMap")*/

    @Select("select* from userinfo")
    public abstract List<UserInfo> selectAll();


    @Select("select* from userinfo where id =#{id}")
    public abstract  UserInfo selectOne(Integer id);



    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into userinfo (username,password,age,gender,phone)" +
    "values(#{username},#{password},#{age},#{gender},#{phone})")
    Integer insert(UserInfo userInfo);

    @Delete("delete from userinfo where id=#{id}")
    public Integer delete(Integer id);

    @Update("update userinfo set username=#{username} where id=#{id}")
            Integer update(UserInfo userInfo);


     @Select("select* from userinfo where username like CONCAT('%',#{username},'%')")
    Integer selectone();
}
